package com.cunjin.repair.comtroller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cunjin.base.controller.BaseController;
import com.cunjin.repair.entity.RepairEntity;
import com.cunjin.repair.service.RepairService;


@Controller
@RequestMapping("/repair")
public class RepairComtroller extends BaseController<RepairEntity> {

	
	@Autowired
	private RepairService service;
	
		//http://localhost:8090/cunjin-dorm/repair/myqueryAll
		@RequestMapping("/myqueryAll")
		@ResponseBody
		public Map<String, Object> myqueryAll(RepairEntity entity) {
			
			Map<String, Object> all = service.queryAll();
			return all;
		}
		
		/**
		 * 分页
		 * @param page
		 * @param rows
		 * @param searchName
		 * @return
		 */
		@RequestMapping("/findWithPage")
		@ResponseBody
		public Map<String, Object>  findWithPage(int page,int rows,String searchName,String chuli) {
		
			Map<String, Object>  fy = service.queryByPage(page,rows,searchName,chuli);
			return fy;
		}
		
		/**
		 * 添加一个班级
		 * @param page
		 * @param rows
		 * @return
		 */
		@RequestMapping("/addRepair")
		@ResponseBody
		public Map<String, Object> addRepair(RepairEntity entity) {
			
			Map<String, Object>  map = service.insert(entity);
					return map;
		}
		
		
		/**
		 * 
		 * 删除
		 * @param dles
		 * @return
		 */
		@RequestMapping("/delRepair")
		@ResponseBody
		public Map<String, Object>  delRepair(String dles) {
			
			String[] split = dles.split(",");
			Map<String, Object>  mydelete = service.deleteByids(split);
			return mydelete;
		}

		/**
		 * 更新一个班级
		 * @param entity
		 * @return
		 */
		@RequestMapping("/updateRepair")
		@ResponseBody
		public Map<String, Object>  updateRepair(RepairEntity entity) {
			
			Map<String, Object>  myupdate = service.update(entity);
			return myupdate;
		}
		
		/**
		 * excel导出
		 * @param entity
		 * @return
		 */
		@RequestMapping("/ExportExcelRepair")
		@ResponseBody
		public Map<String, Object>  ExportExcelRepair(String condition) {
			
			Map<String, Object>  myupdate = service.exportExcel(condition);
			return myupdate;
		}
	
	
}
